package com.tianhua.javs.client.bean;

import com.tianhua.javs.client.utils.KeyWardUtils;

import java.util.List;

/**
 * Description:
 * date: 2022/2/10
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
public class JavsShellVarBean {

    /**
     * 变量标示
     */
    private String varCode;

    /**
     * 是不是业务关键字
     */
    private boolean isBusinessKeyWard;

    /**
     * 是不是javs关键字
     */
    private boolean isJavsKeyWard;

    /**
     * 是不是函数
     */
    private boolean isFunction;

    /**
     * 是不是代表返回的变量
     */
    private boolean isReturn;


    private List<String> paramList;


    public JavsShellVarBean(){}
    public JavsShellVarBean(String varCode){
        this.varCode = varCode;
    }
    public JavsShellVarBean(String varCode,boolean isReturn){
        this.varCode = varCode;
        this.isReturn = isReturn;
    }

    public static JavsShellVarBean ofInstance(String varCode,boolean isReturn){
        JavsShellVarBean javsShellVarBean = new JavsShellVarBean(varCode.trim(),isReturn);
        if(varCode.contains("(")){
            javsShellVarBean.setFunction(true);
        }
        if(KeyWardUtils.isBusinessKeyWard(varCode)){
            javsShellVarBean.setBusinessKeyWard(true);
        }
        if(KeyWardUtils.isJavsKeyWard(varCode)){
            javsShellVarBean.setJavsKeyWard(true);
        }
        return javsShellVarBean;
    }


    public String getVarCode() {
        return varCode;
    }

    public void setVarCode(String varCode) {
        this.varCode = varCode;
    }

    public boolean isBusinessKeyWard() {
        return isBusinessKeyWard;
    }

    public void setBusinessKeyWard(boolean businessKeyWard) {
        isBusinessKeyWard = businessKeyWard;
    }

    public boolean isJavsKeyWard() {
        return isJavsKeyWard;
    }

    public void setJavsKeyWard(boolean javsKeyWard) {
        isJavsKeyWard = javsKeyWard;
    }

    public boolean isFunction() {
        return isFunction;
    }

    public void setFunction(boolean function) {
        isFunction = function;
    }

    public boolean isReturn() {
        return isReturn;
    }

    public void setReturn(boolean aReturn) {
        isReturn = aReturn;
    }

    public List<String> getParamList() {
        return paramList;
    }

    public void setParamList(List<String> paramList) {
        this.paramList = paramList;
    }
}
